/*
 * @Author: chyang0822 270917365@qq.com
 * @Date: 2024-12-27 15:27:32
 * @LastEditors: chyang0822 270917365@qq.com
 * @LastEditTime: 2024-12-27 15:57:03
 * @FilePath: /Project-DMAI-Deploy/tutorials/npp/ch1_get_started/src/main.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置:
 * https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include <npp.h>
#include <stdio.h>

__global__ void testCudaFun(Npp8u *pDst, int num_types) {
    for (int i = 0; i < num_types; i++) {
        printf("%d:%d\n", i, pDst[i]);
    }
}

int main(void) {
    const int num_types = 2 * sizeof(Npp8u);
    Npp8u *host_pDst = (Npp8u *)malloc(num_types);
    Npp8u *dev_pDst = (Npp8u *)nppsMalloc_8u(num_types);
    for (int i = 0; i < num_types; i++) {
        host_pDst[i] = i;
    }

    cudaMemcpy(dev_pDst, host_pDst, num_types, cudaMemcpyHostToDevice);
    testCudaFun<<<1, 1>>>(dev_pDst, num_types);
    cudaDeviceSynchronize();

    return 0;
}